import { IFeidaoAiNodejsComponent } from '@dfeidao/atom-nodejs/interfaces';
import nodejs from '@dfeidao/atom-nodejs/msg/nodejs';
import render from '@dfeidao/atom-nodejs/render/render';
import p001 from './p001';
import p002 from './p002';
import p003 from './p003';

/**
 *
 *
 * @export
 * @param {IFeidaoAiNodejsComponent} fd
 */
export default async function na001(fd: IFeidaoAiNodejsComponent) {
	// todo
	const pn = fd.data.params['page-no'] as string;
	let pno = 1;
	if (pn) {
		pno = parseInt(pn, 10);
	}

	console.log(pno);
	// todo

	const res = await nodejs<{ res: Array<{}>; c: number; }>(fd.data.actionid, fd.data.sessionid, 'customer-care/zj-000003/s001', {
		industry_domain_name: '', page_no: 1
	});
	console.info(res);
	if (res.res.length > 1) {
		render(fd.data.node, res.res, p001, 'p001');
		render(fd.data.node, { page_no: 1, total: res.c }, p002, 'p002');
	} else {
		render(fd.data.node, '', p003, 'p003');
	}

}
